# coding:utf-8
'''
Created on 2010-1-4

@author: Jason Green
@author-email: guileen@gmail.com
'''
import socket
import sys

HOST, PORT = "localhost", 9999
data = " asdfasdfas \n\n\n\tfasdf asdfggg"



class KeyAgent:
    def __init__(self):
        self.connect()
        
    def connect(self):
        # Create a socket (SOCK_STREAM means a TCP socket)
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        # Connect to server and send data
        self.sock.connect((HOST, PORT))
    
    def get_key(self,raw_key):
        self.sock.send(raw_key + "\n")
        # Receive data from the server and shut down
        return self.sock.recv(1024)
    
    def shut_down(self):
        self.sock.close()
agent=KeyAgent()
agent.get_key(' asdfasdfxxxsdf')
agent.shut_down()
